Skip to content

MDEV-40408 btr_page_reorganize_low() uses the buffer pool just to obt…#5401

Open
iMineLink wants to merge 1 commit into
11.8from
MDEV-40408
Open

MDEV-40408 btr_page_reorganize_low() uses the buffer pool just to obt…#5401
iMineLink wants to merge 1 commit into
11.8from
MDEV-40408

Conversation

@iMineLink

Copy link
Copy Markdown
Contributor

…ain a scratch block

Add a pool of scratch blocks, btr_scratch_pool_t, to be used instead of the global buffer pool in the page-reorganization operations, when a scratch block is needed.
Removes the needs of obtaining the buf_pool.mutex in such functions, and any delay while holding at least page X-latch that it might have caused.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a buffer-pool-independent scratch block pool (btr_scratch_pool_t) to optimize page reorganization operations by avoiding global buffer pool mutex contention. The reviewer feedback focuses on replacing raw pthread and custom condition variable primitives with their mysql_cond_* counterparts to ensure proper Performance Schema instrumentation and consistency. Additionally, the reviewer suggests introducing a debug-only active block counter (n_active) to assert that no scratch blocks are leaked when the pool is closed.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread storage/innobase/btr/btr0btr.cc
Comment thread storage/innobase/btr/btr0btr.cc
Comment thread storage/innobase/btr/btr0btr.cc
Comment thread storage/innobase/btr/btr0btr.cc
Comment thread storage/innobase/btr/btr0btr.cc
Comment thread storage/innobase/btr/btr0btr.cc
Comment thread storage/innobase/btr/btr0btr.cc
Comment thread storage/innobase/btr/btr0btr.cc
Comment thread storage/innobase/btr/btr0btr.cc

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a dedicated “scratch block” pool for InnoDB page reorganization paths to avoid using the global buffer pool (and therefore avoid taking buf_pool.mutex) when a temporary block is needed during page rebuild/reorganization.

Changes:

  • Add btr_scratch_pool_t plus public init/close/get/put APIs, and switch btr_page_reorganize_low() to use it instead of buf_block_alloc()/free().
  • Switch page_zip_reorganize() to use the scratch pool instead of buffer-pool allocation.
  • Wire scratch pool lifecycle into server startup/shutdown (and mariabackup initialization).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
storage/innobase/srv/srv0start.cc Close the scratch pool during InnoDB shutdown.
storage/innobase/srv/srv0srv.cc Initialize the scratch pool during InnoDB boot.
storage/innobase/page/page0zip.cc Use scratch blocks for compressed-page reorganization temp storage.
storage/innobase/include/buf0buf.h Allow buf_page_t::set_state() to optionally skip asserting buf_pool.mutex ownership.
storage/innobase/include/btr0btr.h Declare scratch pool lifecycle + get/put APIs.
storage/innobase/btr/btr0btr.cc Implement scratch pool and switch page reorganization to use it.
extra/mariabackup/xtrabackup.cc Initialize the scratch pool in the mariabackup startup flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread storage/innobase/btr/btr0btr.cc
…ain a scratch block

Add a pool of scratch blocks, btr_scratch_pool_t, to be used instead
of the global buffer pool in the page-reorganization operations,
when a scratch block is needed.
Removes the needs of obtaining the buf_pool.mutex in such functions,
and any delay while holding at least page X-latch that it might have
caused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants